﻿using FastSql.Core;
using SignalrChat.Models;

namespace SignalrChat.DbServer
{
    public class UsersDao
    {
        public static List<Users> GetUsers()
        {
            return new CreateSql<Users>().Select().QueryList();
        }

        public static Users getById(Guid Id)
        {

            return new CreateSql<Users>().Select().Where(w => w.Id == Id).QueryFirst();
        }

        public static bool AddUsers(Users users)
        {

            return new CreateSql<Users>().Insert().Add(users);
        }

        public static bool UpdateUsers(Users users)
        {

            return new CreateSql<Users>().Updata().Where(w => w.Id == users.Id).Modify(users);
        }

        public static bool UpdateLoginTime(Guid Id, DateTime dateTime)
        {
            return new CreateSql<Users>()
                .Updata(u => new { u.LoginTime })
                .Where(w => w.Id == Id)
                .Modify(new { LoginTime = dateTime });
        }
        public static bool DeleteUsers(Guid Id)
        {

            return new CreateSql<Users>().Delete().Where(w => w.Id == Id).Remove();
        }
    }
}
